{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ZqmhthnKYNve"
      },
      "source": [
        "# Flow – Intelligent Agent for Daily Efficiency"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "nPPyvagreZ_i"
      },
      "source": [
        "# Description"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "5wMZC3_0edNZ"
      },
      "source": [
        "This agent uses a custom DuckDuckGo search tool to intelligently retrieve and summarize real-time information based on user queries."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "mNFEBTyAek8E"
      },
      "source": [
        "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Flow_Intelligent_Agent_PraisonAI.ipynb)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "mHpIJFsZYNvi"
      },
      "source": [
        "## Tools\n",
        "- `praisonaiagents` – Intelligent Agent framework\n",
        "- `duckduckgo-search` – Custom search tool\n",
        "- `pyyaml` – YAML config\n",
        "- `openai` – LLM backend"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "K1QOdZ8SYqoF"
      },
      "source": [
        "# Dependencies"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "zZOiRidoYNvj"
      },
      "outputs": [],
      "source": [
        "!pip install praisonaiagents duckduckgo-search pyyaml openai"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "_9jyGJrOYyKh"
      },
      "source": [
        "# Set your OpenAI API Key securely"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "7huxRijxYNvk"
      },
      "outputs": [],
      "source": [
        "import os\n",
        "os.environ['OPENAI_API_KEY'] = 'your api key'  # Replace with your actual OpenAI key"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "E3naWfHNYNvk"
      },
      "source": [
        "## YAML Prompt\n",
        "Define multiple agents and their roles."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "kYST2rZqYNvl"
      },
      "outputs": [],
      "source": [
        "import yaml\n",
        "\n",
        "yaml_prompt = '''\n",
        "agents:\n",
        "  - name: FlowAgent\n",
        "    description: Intelligent daily workflow assistant\n",
        "  - name: ChileAtiendeAI\n",
        "    description: Government support assistant for Chile\n",
        "  - name: ClinicalTrialMatcher\n",
        "    description: Match patients to trials using input medical info\n",
        "  - name: ChillWorkEmailAgent\n",
        "    description: Automate email replies and scheduling\n",
        "'''\n",
        "\n",
        "config = yaml.safe_load(yaml_prompt)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "tBryRalYYNvl"
      },
      "source": [
        "## Main\n",
        "Initialize agent with a custom DuckDuckGo tool and simulate a task."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 673,
          "referenced_widgets": [
            "865a918fc4d54fd0a110ea3eb7fe4215",
            "c70a26d2c54549888067f65c366bdb9b"
          ]
        },
        "id": "1mMAS_1PYNvl",
        "outputId": "d3aacdd3-5e01-460b-ae66-385f6a62c1eb"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╭─ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> ────────────────────────────────────────────────────────────────────────────────────────────────────╮</span>\n",
              "<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>                                                                                                                 <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
              "<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>  <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">👤 Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">FlowAgent</span>                                                                                            <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
              "<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>  <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span>                                                                                                <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
              "<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>  <span style=\"color: #86a789; text-decoration-color: #86a789; font-weight: bold\">Tools:</span> <span style=\"color: #b4d4ff; text-decoration-color: #b4d4ff; font-style: italic\">internet_search_tool</span>                                                                                    <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
              "<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>                                                                                                                 <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">│</span>\n",
              "<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n",
              "\u001b[38;2;210;227;200m│\u001b[0m                                                                                                                 \u001b[38;2;210;227;200m│\u001b[0m\n",
              "\u001b[38;2;210;227;200m│\u001b[0m  \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mFlowAgent\u001b[0m                                                                                            \u001b[38;2;210;227;200m│\u001b[0m\n",
              "\u001b[38;2;210;227;200m│\u001b[0m  \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m                                                                                                \u001b[38;2;210;227;200m│\u001b[0m\n",
              "\u001b[38;2;210;227;200m│\u001b[0m  \u001b[1;38;2;134;167;137mTools:\u001b[0m \u001b[3;38;2;180;212;255minternet_search_tool\u001b[0m                                                                                    \u001b[38;2;210;227;200m│\u001b[0m\n",
              "\u001b[38;2;210;227;200m│\u001b[0m                                                                                                                 \u001b[38;2;210;227;200m│\u001b[0m\n",
              "\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
            ],
            "text/plain": []
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008000; text-decoration-color: #008000\">╭─────────────────────────────────────────────────── Tool Call ───────────────────────────────────────────────────╮</span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">Agent FlowAgent is calling function 'internet_search_tool' with arguments: {'query': 'latest open-source AI </span>    <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">agent framework 2023'}</span>                                                                                          <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\u001b[32m╭─\u001b[0m\u001b[32m──────────────────────────────────────────────────\u001b[0m\u001b[32m Tool Call \u001b[0m\u001b[32m──────────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n",
              "\u001b[32m│\u001b[0m \u001b[1;36mAgent FlowAgent is calling function 'internet_search_tool' with arguments: {'query': 'latest open-source AI \u001b[0m    \u001b[32m│\u001b[0m\n",
              "\u001b[32m│\u001b[0m \u001b[1;36magent framework 2023'}\u001b[0m                                                                                          \u001b[32m│\u001b[0m\n",
              "\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008000; text-decoration-color: #008000\">╭─────────────────────────────────────────────────── Tool Call ───────────────────────────────────────────────────╮</span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">Function 'internet_search_tool' returned: \"OpenAgents - An Open Framework for Connecting AI Agents at Scale - </span>  <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">https://openagents.org/\\nAutoGen: Enabling Next-Gen LLM Applications via Multi-Agent ... - </span>                     <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">https://www.microsoft.com/en-us/research/publication/autogen-enabling-next-gen-llm-applications-via-multi-agent</span> <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">-conversation-framework/\\nOpen-source framework to build, manage and run useful Autonomous AI Agents - </span>         <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">│</span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">https://github.com/TransformerOptimus/SuperAGI\"</span>                                                                 <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\u001b[32m╭─\u001b[0m\u001b[32m──────────────────────────────────────────────────\u001b[0m\u001b[32m Tool Call \u001b[0m\u001b[32m──────────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n",
              "\u001b[32m│\u001b[0m \u001b[1;36mFunction 'internet_search_tool' returned: \"OpenAgents - An Open Framework for Connecting AI Agents at Scale - \u001b[0m  \u001b[32m│\u001b[0m\n",
              "\u001b[32m│\u001b[0m \u001b[1;36mhttps://openagents.org/\\nAutoGen: Enabling Next-Gen LLM Applications via Multi-Agent ... - \u001b[0m                     \u001b[32m│\u001b[0m\n",
              "\u001b[32m│\u001b[0m \u001b[1;36mhttps://www.microsoft.com/en-us/research/publication/autogen-enabling-next-gen-llm-applications-via-multi-agent\u001b[0m \u001b[32m│\u001b[0m\n",
              "\u001b[32m│\u001b[0m \u001b[1;36m-conversation-framework/\\nOpen-source framework to build, manage and run useful Autonomous AI Agents - \u001b[0m         \u001b[32m│\u001b[0m\n",
              "\u001b[32m│\u001b[0m \u001b[1;36mhttps://github.com/TransformerOptimus/SuperAGI\"\u001b[0m                                                                 \u001b[32m│\u001b[0m\n",
              "\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "865a918fc4d54fd0a110ea3eb7fe4215",
              "version_major": 2,
              "version_minor": 0
            },
            "text/plain": [
              "Output()"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
            ],
            "text/plain": []
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 6.1s</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\u001b[2mResponse generated in 6.1s\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮</span>\n",
              "<span style=\"color: #008080; text-decoration-color: #008080\">│</span> What's the latest open-source AI agent framework?                                                               <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
              "<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
              "\u001b[36m│\u001b[0m What's the latest open-source AI agent framework?                                                               \u001b[36m│\u001b[0m\n",
              "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮</span>\n",
              "<span style=\"color: #008080; text-decoration-color: #008080\">│</span> Here are some of the latest open-source AI agent frameworks:                                                    <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
              "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                                                                                                 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
              "<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">OpenAgents</span>: An open framework for connecting AI agents at scale. More information can be found on their      <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
              "<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span><a href=\"https://openagents.org/\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">website</span></a>.                                                                                                     <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
              "<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">AutoGen</span>: A framework by Microsoft Research that enables next-gen LLM applications via multi-agent            <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
              "<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>conversation. You can read more about it <a href=\"https://www.microsoft.com/en-us/research/publication/autogen-enabling-next-gen-llm-applications-via-multi-agent-conversation-framework/\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">here</span></a>.                                                               <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
              "<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">SuperAGI</span>: An open-source framework to build, manage, and run useful autonomous AI agents. Check out their    <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
              "<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span><a href=\"https://github.com/TransformerOptimus/SuperAGI\" target=\"_blank\"><span style=\"color: #000080; text-decoration-color: #000080; text-decoration: underline\">GitHub repository</span></a> for more details.                                                                          <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
              "<span style=\"color: #008080; text-decoration-color: #008080\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
              "\u001b[36m│\u001b[0m Here are some of the latest open-source AI agent frameworks:                                                    \u001b[36m│\u001b[0m\n",
              "\u001b[36m│\u001b[0m                                                                                                                 \u001b[36m│\u001b[0m\n",
              "\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mOpenAgents\u001b[0m: An open framework for connecting AI agents at scale. More information can be found on their      \u001b[36m│\u001b[0m\n",
              "\u001b[36m│\u001b[0m \u001b[1;33m   \u001b[0m\u001b]8;id=900045;https://openagents.org/\u001b\\\u001b[4;34mwebsite\u001b[0m\u001b]8;;\u001b\\.                                                                                                     \u001b[36m│\u001b[0m\n",
              "\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mAutoGen\u001b[0m: A framework by Microsoft Research that enables next-gen LLM applications via multi-agent            \u001b[36m│\u001b[0m\n",
              "\u001b[36m│\u001b[0m \u001b[1;33m   \u001b[0mconversation. You can read more about it \u001b]8;id=398797;https://www.microsoft.com/en-us/research/publication/autogen-enabling-next-gen-llm-applications-via-multi-agent-conversation-framework/\u001b\\\u001b[4;34mhere\u001b[0m\u001b]8;;\u001b\\.                                                               \u001b[36m│\u001b[0m\n",
              "\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mSuperAGI\u001b[0m: An open-source framework to build, manage, and run useful autonomous AI agents. Check out their    \u001b[36m│\u001b[0m\n",
              "\u001b[36m│\u001b[0m \u001b[1;33m   \u001b[0m\u001b]8;id=898758;https://github.com/TransformerOptimus/SuperAGI\u001b\\\u001b[4;34mGitHub repository\u001b[0m\u001b]8;;\u001b\\ for more details.                                                                          \u001b[36m│\u001b[0m\n",
              "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Here are some of the latest open-source AI agent frameworks:\n",
            "\n",
            "1. **OpenAgents**: An open framework for connecting AI agents at scale. More information can be found on their [website](https://openagents.org/).\n",
            "\n",
            "2. **AutoGen**: A framework by Microsoft Research that enables next-gen LLM applications via multi-agent conversation. You can read more about it [here](https://www.microsoft.com/en-us/research/publication/autogen-enabling-next-gen-llm-applications-via-multi-agent-conversation-framework/).\n",
            "\n",
            "3. **SuperAGI**: An open-source framework to build, manage, and run useful autonomous AI agents. Check out their [GitHub repository](https://github.com/TransformerOptimus/SuperAGI) for more details.\n"
          ]
        }
      ],
      "source": [
        "from praisonaiagents import Agent\n",
        "from duckduckgo_search import DDGS\n",
        "\n",
        "def internet_search_tool(query: str):\n",
        "    ddgs = DDGS()\n",
        "    results = []\n",
        "    for res in ddgs.text(keywords=query, max_results=3):\n",
        "        results.append(f\"{res['title']} - {res['href']}\")\n",
        "    return \"\\n\".join(results)\n",
        "\n",
        "# Initialize the main agent (FlowAgent)\n",
        "flow_config = config['agents'][0]\n",
        "flow_agent = Agent(\n",
        "    name=flow_config['name'],\n",
        "    instructions=flow_config['description'],\n",
        "    tools=[internet_search_tool]\n",
        ")\n",
        "\n",
        "response = flow_agent.start(\"What's the latest open-source AI agent framework?\")\n",
        "print(response)"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.x"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}